package demo1;

public class Computer {
    public void powerOn() {
        System.out.println("电脑开机！");
    }
    public void powerOff() {
        System.out.println("电脑关机! ");
    }

    public void useService(USB usb) {
        usb.openDevice();
        if(usb instanceof Mouse) {
            ((Mouse) usb).click();
        } else if(usb instanceof KeyBoard) {
            ((KeyBoard) usb).input();
        }
        usb.closeDevice();
    }
}
